#ifndef DIAGRAMWINDOW_H
#define DIAGRAMWINDOW_H

#include <QMainWindow>
#include <QPair>

QT_BEGIN_NAMESPACE
class QAction;
class QGraphicsItem;
class QGraphicsScene;
class QGraphicsView;
class Link;
class Node;
QT_END_NAMESPACE

class DiagramWindow : public QMainWindow
{
    Q_OBJECT

public:
    DiagramWindow();

private slots:
    void addNode();
    void addLink();
    void del();
    void cut();
    void copy();
    void paste();
    void bringToFront();
    void sendToBack();
    void properties();
    void updateActions();

    void slotSaveFile();
    void slotOpenFile();
    void slotBFS();

private:
    void addNode(int iID, QPoint point, QString text);
    void addLink(int iFromID, int iToID);


private:
    typedef QPair<Node *, Node *> NodePair;

    void createActions();
    void createMenus();
    void createToolBars();
    void setZValue(int z);
    void setupNode(Node *node);
    Node *selectedNode() const;
    Link *selectedLink() const;
    NodePair selectedNodePair() const;

    QMenu *m_pFileMenu;
    QMenu *m_pEditMenu;
    QMenu *m_pSearchMenu;

    QToolBar *m_pEditToolBar;
    QAction *m_pExitAction;
    QAction *m_pAddNodeAction;
    QAction *m_pAddLinkAction;
    QAction *m_pDeleteAction;
    QAction *m_pCutAction;
    QAction *m_pCopyAction;
    QAction *m_pPasteAction;
    QAction *m_pBringToFrontAction;
    QAction *m_pSendToBackAction;
    QAction *m_pPropertiesAction;

    QAction *m_pSaveAction;
    QAction *m_pOpenAction;

    QAction *m_pBFSAction;

    QGraphicsScene *m_pScene;
    QGraphicsView *m_pView;

    QHash<int, Node *> m_nodeIDHash;

    int m_iMinZ;
    int m_iMaxZ;
    int m_iSeqNumber;
};

#endif
